package cn.heima.com;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

public class DateDemo7 {
    public static void main(String[] args)  {
        getWeek();
    }
    //用程序判断2018年2月14日是星期几
    public  static  void getWeek(){
        LocalDate ofTime = LocalDate.of(2018, 02, 14);
        DayOfWeek dayOfWeek = ofTime.getDayOfWeek();
        System.out.println(dayOfWeek);
    }
    //获取当前的日期,并把这个日期转换为指定格式的字符串,如2088-08-08 08:08:08。
    public static void getMethod(){
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String result = sdf.format(date);
        System.out.println(result);
    }
    public void getHuan() throws ParseException {
        String  s = "2018-03-04";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date= simpleDateFormat.parse(s);
        SimpleDateFormat sd = new SimpleDateFormat("yyyy年MM月dd日");
        String result = sd.format(date);
        System.out.println(result);
    }
}
